import 'package:flutter/material.dart';
import 'package:flutter_demo/stateful/StatefulWidgetDemo.dart';

class TableDataWidget extends StatelessWidget {
  const TableDataWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      /* 设置应用头部 */
      appBar: AppBar(
        title: const Text('DataTable'),
        centerTitle: true, /* 是否居中标题 */
        leading: const Icon(Icons.menu), /* 左侧图标 */
        actions: const [ /* 右侧 更多操作 */
          Icon(Icons.settings),
        ],
        elevation: 100, /* 头部阴影 */
      ),
      // body: const BodyWidget(),
      body: const UserList(),
    );
  }
}

class UserList extends StatefulWidget {
  const UserList({super.key});

  @override
  State<StatefulWidget> createState() => _UserListState();

}

class _UserListState extends State<UserList> {
  @override
  Widget build(BuildContext context) {
    return Container(
      height: 800,
      child: SingleChildScrollView(
        scrollDirection: Axis.vertical,
        child: DataTable(
          columns: [
            DataColumn(label: Text('姓名')),
            DataColumn(label: Text('年龄')),
            DataColumn(label: Text('性别')),
            DataColumn(label: Text('简介')),
          ],
          rows: [
            DataRow(cells: [
              DataCell(Text('张三')),
              DataCell(Text('18')),
              DataCell(Text('男')),
              DataCell(Text('一个男人'))
            ]),
            DataRow(cells: [
              DataCell(Text('李四')),
              DataCell(Text('38')),
              DataCell(Text('女')),
              DataCell(Text('一个女人'))
            ]),
            DataRow(cells: [
              DataCell(Text('王五')),
              DataCell(Text('18')),
              DataCell(Text('男')),
              DataCell(Text('一个男人'))
            ]),
            DataRow(cells: [
              DataCell(Text('赵六')),
              DataCell(Text('33')),
              DataCell(Text('男')),
              DataCell(Text('一个男人'))
            ]),
          ],
        ),
      ),
    );
  }

}